package July;

import java.util.Scanner;

public class Day0731 {
    //汽水瓶
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()){
            int n = scanner.nextInt();
            int res = n/2;
            if (res != 0)
                System.out.println(res);
        }
    }


    //查找两个字符串a，b中的最长公共子串
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String a = scanner.nextLine();
            String b = scanner.nextLine();

            String max = a.length() >= b.length() ? a:b;
            String min = a.length() <= b.length() ? a:b;

            int count = 0;
            String str = "";

            for (int i = 0; i < min.length(); i++) {
                for (int j = i+1; j <= min.length(); j++) {
                    if (max.contains(min.substring(i,j)) && j-i >count){
                        count = j-i;
                        str = min.substring(i,j);
                    }
                }
            }
            System.out.println(str);
        }
    }
}
